package com.neusoft.neuiotms.dcam.fixed.model;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import org.hibernate.validator.constraints.Length;

import com.neusoft.bizcore.web.jpa.model.AbstractAuditModel;
import com.neusoft.bizcore.web.jpa.model.Comment;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

@Getter
@Setter
@ToString
@Entity
@Table(name = "neuiot_contract_item")
@org.hibernate.annotations.Table(appliesTo = "neuiot_contract_item", comment = "合同详细表")
public class ContractItem extends AbstractAuditModel {

    private static final long serialVersionUID = 1L;

    @ManyToOne(cascade = {CascadeType.MERGE, CascadeType.PERSIST }, fetch = FetchType.LAZY)
    private Contract contract;

    @ManyToOne
    private AssetType assetType;

    @ManyToOne
    private Product product;

    @ManyToOne
    private SpareType spareType;

    //    @ManyToOne
    //    private GoodsFile goodsFile;

    @NotNull(message = "数量不能为空")
    @Comment("int(11) NULL COMMENT '数量'")
    private int count = 1;

    @NotNull(message = "已验收数量不能为空")
    @Comment("int(11) NULL COMMENT '已验收数量'")
    private int acceptedCount = 0;

    /** 单个资产价格 */
    @NotNull(message = "单个资产价格不能为空")
    @Comment("double(12,2) NULL COMMENT '单个资产价格'")
    private Double amount = 0.0D;

    /** 合同项描述 */
    @Length(max = 1023, message = "合同项描述不能超过{max}位")
    @Comment("varchar(1023) NULL COMMENT '资产名称'")
    private String description;

    /** 类型 */
    @Length(max = 255, message = "类型不能超过{max}位")
    @Column(length = 255, nullable = true)
    private String type;

    /** 规格型号 */
    @Length(max = 100, message = "规格型号不能超过{max}位")
    @Column(length = 100, nullable = true)
    @Comment("varchar(100) NOT NULL COMMENT '规格型号'")
    private String standard;

}
